
#include "xege.h"
namespace xege {

#define XR XEGEGET_R
#define XG XEGEGET_G
#define XB XEGEGET_B
#define XA XEGEGET_A

	PAINT::PAINT () {}
	
	PAINT& PAINT::xyprintf (std::string str , int x, int y, COLOR C) {
		// IMAGE
		return *this;
	}
	PAINT& PAINT::outtextxy (std::string str, int x, int y, COLOR C) {
		
	}

	// RF 是 Really Fast 的意思
	PAINT& PAINT::drawPixelRF (short x, short y, color_t c) {
		SDL_SetRenderDrawColor (rPic, XR (c), XG (c), XB (c), XA (c));
		SDL_RenderDrawPoint (rPic, offset.x + x, offset.y + y);
		return *this;
	}
	PAINT& PAINT::drawPixelRF (short x, short y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
		SDL_SetRenderDrawColor (rPic, r, g, b, a);
		SDL_RenderDrawPoint (rPic, offset.x + x, offset.y + y);
		return *this;
	}
	PAINT& PAINT::drawPixelRF (short x, short y) {
		SDL_RenderDrawPoint (rPic, offset.x + x, offset.y + y);
		return *this;
	}
	PAINT& PAINT::drawFillRectRF (short x, short y, short w, short h) {
		SDL_Rect rect {x, offset.y + y, w, h};
		SDL_RenderDrawRect (rPic, &rect);
		return *this;
	}
	// SDL_RenderDrawLine
	// SDL_RenderDrawLines
	// SDL_RenderDrawPoints
	// SDL_RenderDrawRects


	// 画一个点
	PAINT& PAINT::drawPixel (short x, short y) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::drawPixel (short x, short y, color_t C) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	PAINT& PAINT::drawPixel (short x, short y, COLOR C) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, C.r, C.g, C.b, C.a);
		return *this;
	}
	PAINT& PAINT::putPixel (short x, short y) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::putPixel (short x, short y, color_t C) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	PAINT& PAINT::putPixel (short x, short y, COLOR C) {
		pixelRGBA (rPic, offset.x + x, offset.y + y, C.r, C.g, C.b, C.a);
		return *this;
	}

/*
linestyle
线型，可以是以下值：
值	含义
SOLID_LINE	线形为实线。
CENTER_LINE	线形为：－－－－－－－－－－－－
DOTTED_LINE	线形为：●●●●●●●●●●●●
DASHED_LINE	线形为：－●－●－●－●－●－●
NULL_LINE	线形为不可见。
USERBIT_LINE	线形样式是自定义的，依赖于 upattern 参数。


fillstyle
填充类型

*/

	// 画一条横线
	PAINT& PAINT::drawLineH (short x1, short x2, short y) {
		hlineRGBA (rPic, offset.x + x1, offset.x + x2, offset.y + y, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一条横线
	PAINT& PAINT::drawLineH (short x1, short x2, short y, color_t C) {
		hlineRGBA (rPic, offset.x + x1, offset.x + x2, offset.y + y, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一条横线
	PAINT& PAINT::drawLineH (short x1, short x2, short y, COLOR C) {
		hlineRGBA (rPic, offset.x + x1, offset.x + x2, offset.y + y, C.r, C.g, C.b, C.a);
		return *this;
	}
	// 画一条竖线
	PAINT& PAINT::drawLineV (short x, short y1, short y2) {
		vlineRGBA (rPic, offset.x + x, offset.y + y1, offset.y + y2, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一条竖线
	PAINT& PAINT::drawLineV (short x, short y1, short y2, color_t C) {
		vlineRGBA (rPic, offset.x + x, offset.y + y1, offset.y + y2, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一条线
	PAINT& PAINT::drawLine (short x1, short y1, short x2, short y2, color_t C) {
		lineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一条线
	PAINT& PAINT::drawLine (short x1, short y1, short x2, short y2) {
		lineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一条抗锯齿线
	PAINT& PAINT::drawLineAA (short x1, short y1, short x2, short y2) {
		aalineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一条抗锯齿线
	PAINT& PAINT::drawLineAA (short x1, short y1, short x2, short y2, color_t C) {
		aalineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 有宽度的线
	PAINT& PAINT::drawLineW (short x1, short y1, short x2, short y2, Uint8 width) {
		thickLineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, width, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 有宽度的线
	PAINT& PAINT::drawLineW (short x1, short y1, short x2, short y2, Uint8 width, color_t C) {
		thickLineRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, width, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}


	// 画一个矩形
	PAINT& PAINT::drawRect (short x1, short y1, short x2, short y2) {
		rectangleRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个矩形
	PAINT& PAINT::drawRect (short x1, short y1, short x2, short y2, color_t C) {
		rectangleRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个圆角矩形
	PAINT& PAINT::drawRoundRect (short x1, short y1, short x2, short y2, int rad) {
		roundedRectangleRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, rad, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个圆角矩形
	PAINT& PAINT::drawRoundRect (short x1, short y1, short x2, short y2, int rad, color_t C) {
		roundedRectangleRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, rad, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个填充矩形
	PAINT& PAINT::drawFillRect (short x1, short y1, short x2, short y2) {
		boxRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个填充矩形
	PAINT& PAINT::drawFillRect (short x1, short y1, short x2, short y2, color_t C) {
		boxRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// using drawBox = drawFillRect;
	// 画一个填充圆角矩形
	PAINT& PAINT::drawFillRoundRect (short x1, short y1, short x2, short y2, int rad) {
		roundedBoxRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, rad, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个填充圆角矩形
	PAINT& PAINT::drawFillRoundRect (short x1, short y1, short x2, short y2, int rad, color_t C) {
		roundedBoxRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, rad, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}


	// 画三角形（线）
	PAINT& PAINT::drawTrigon (short x1, short y1, short x2, short y2, short x3, short y3) {
		trigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画三角形（线）
	PAINT& PAINT::drawTrigon (short x1, short y1, short x2, short y2, short x3, short y3, color_t C) {
		trigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画抗锯齿三角形
	PAINT& PAINT::drawTrigonAA (short x1, short y1, short x2, short y2, short x3, short y3) {
		aatrigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画抗锯齿三角形
	PAINT& PAINT::drawTrigonAA (short x1, short y1, short x2, short y2, short x3, short y3, color_t C) {
		aatrigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画填充三角形
	PAINT& PAINT::drawFillTrigon (short x1, short y1, short x2, short y2, short x3, short y3) {
		filledTrigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画填充三角形
	PAINT& PAINT::drawFillTrigon (short x1, short y1, short x2, short y2, short x3, short y3, color_t C) {
		filledTrigonRGBA (rPic, offset.x + x1, offset.y + y1, offset.x + x2, offset.y + y2, offset.x + x3, offset.y + y3, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}

	// 画多边形（线）
	PAINT& PAINT::drawPoly (short* px, short* py, uint n) {
		polygonRGBA (rPic, px, py, n, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画多边形（线）
	PAINT& PAINT::drawPoly (short* px, short* py, uint n, color_t C) {
		polygonRGBA (rPic, px, py, n, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画抗锯齿多边形（线）
	PAINT& PAINT::drawPolyAA (short* px, short* py, uint n) {
		aapolygonRGBA (rPic, px, py, n, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画抗锯齿多边形（线）
	PAINT& PAINT::drawPolyAA (short* px, short* py, uint n, color_t C) {
		aapolygonRGBA (rPic, px, py, n, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画填充多边形
	PAINT& PAINT::drawFillPoly (short* px, short* py, uint n) {
		filledPolygonRGBA (rPic, px, py, n, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画填充多边形
	PAINT& PAINT::drawFillPoly (short* px, short* py, uint n, color_t C) {
		filledPolygonRGBA (rPic, px, py, n, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	/*
	** 很难搞阿，我暂时还不是很确定这个 surface 用啥来传……
	PAINT& drawTexturePoly (short* px, short* py, uint n, SDL_Surface* texture, int dx, int dy) {
		texturedPolygon (rPic, px, py, n, texture, dx, dy);
	}
	PAINT& drawTexturePoly (short* px, short* py, uint n, SDL_Surface &texture, int dx, int dy) {
		texturedPolygon (rPic, px, py, n, &texture, dx, dy);
	}
	*/
	PAINT& PAINT::drawArc (short x, short y, short rad, short start, short end) {
		arcRGBA (rPic, x, y, rad, start, end, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::drawArc (short x, short y, short rad, short start, short end, color_t C) {
		arcRGBA (rPic, x, y, rad, start, end, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个椭圆
	PAINT& PAINT::drawEsplise (short left, short top, short right, short bottom) {
		ellipseRGBA (rPic, left, top, right, bottom, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个椭圆
	PAINT& PAINT::drawEsplise (short left, short top, short right, short bottom, color_t C) {
		ellipseRGBA (rPic, left, top, right, bottom, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个抗锯齿椭圆
	PAINT& PAINT::drawEspliseAA (short left, short top, short right, short bottom) {
		aaellipseRGBA (rPic, left, top, right, bottom, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个抗锯齿椭圆
	PAINT& PAINT::drawEspliseAA (short left, short top, short right, short bottom, color_t C) {
		aaellipseRGBA (rPic, left, top, right, bottom, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个填充椭圆
	PAINT& PAINT::drawFillEsplise (short left, short top, short right, short bottom) {
		filledEllipseRGBA (rPic, left, top, right, bottom, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个填充椭圆
	PAINT& PAINT::drawFillEsplise (short left, short top, short right, short bottom, color_t C) {
		filledEllipseRGBA (rPic, left, top, right, bottom, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}


	// 画一个圆
	PAINT& PAINT::drawCircle (short x, short y, short r) {
		circleRGBA (rPic, offset.x + x, offset.y + y, r, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个圆
	PAINT& PAINT::drawCircle (short x, short y, short r, color_t C) {
		circleRGBA (rPic, offset.x + x, offset.y + y, r, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个抗锯齿圆
	PAINT& PAINT::drawCircleAA (short x, short y, short r) {
		aacircleRGBA (rPic, offset.x + x, offset.y + y, r, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个抗锯齿圆
	PAINT& PAINT::drawCircleAA (short x, short y, short r, color_t C) {
		aacircleRGBA (rPic, offset.x + x, offset.y + y, r, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画一个填充圆
	PAINT& PAINT::drawFillCircle (short x, short y, short r) {
		filledCircleRGBA (rPic, offset.x + x, offset.y + y, r, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画一个填充圆
	PAINT& PAINT::drawFillCircle (short x, short y, short r, color_t C) {
		filledCircleRGBA (rPic, offset.x + x, offset.y + y, r, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}


	// 画扇形线（圆心坐标，半径，开始位置，结束位置（角度制，0 为右，90 为下，-90 为上））
	PAINT& PAINT::drawPie (short x, short y, short rad, short start, short end) {
		pieRGBA (rPic, offset.x + x, offset.y + y, rad, start, end, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画扇形线（圆心坐标，半径，开始位置，结束位置（角度制，0 为右，90 为下，-90 为上），颜色）
	PAINT& PAINT::drawPie (short x, short y, short rad, short start, short end, color_t C) {
		pieRGBA (rPic, offset.x + x, offset.y + y, rad, start, end, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	// 画填充扇形（圆心坐标，半径，开始位置，结束位置（角度制，0 为右，90 为下，-90 为上））
	PAINT& PAINT::drawFillPie (short x, short y, short rad, short start, short end) {
		filledPieRGBA (rPic, offset.x + x, offset.y + y, rad, start, end, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画填充扇形（圆心坐标，半径，开始位置，结束位置（角度制，0 为右，90 为下，-90 为上），颜色）
	PAINT& PAINT::drawFillPie (short x, short y, short rad, short start, short end, color_t C) {
		filledPieRGBA (rPic, offset.x + x, offset.y + y, rad, start, end, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}

	// 画贝塞尔曲线
	PAINT& PAINT::drawBezier (short* px, short* py, uint n, uint s) {
		bezierRGBA (rPic, px, py, n, s, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	// 画贝塞尔曲线
	PAINT& PAINT::drawBezier (short* px, short* py, uint n, uint s, color_t C) {
		bezierRGBA (rPic, px, py, n, s, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}

	PAINT& PAINT::setDrawFont (const void *fontdata, Uint32 cw, Uint32 ch) {
		gfxPrimitivesSetFont (fontdata, cw, ch);
		return *this;
	}
	PAINT& PAINT::setDrawFontRotation (Uint32 rotation) {
		gfxPrimitivesSetFontRotation (rotation);
		return *this;
	}
	PAINT& PAINT::drawChar (short x, short y, char c) {
		characterRGBA (rPic, x, y, c, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::drawChar (short x, short y, char c, color_t C) {
		characterRGBA (rPic, x, y, c, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	PAINT& PAINT::drawString (short x, short y, std::string str) {
		stringRGBA (rPic, x, y, str.c_str (), FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::drawString (short x, short y, std::string str, color_t C) {
		stringRGBA (rPic, x, y, str.c_str (), XR(C), XG(C), XB(C), XA(C));
		return *this;
	}
	PAINT& PAINT::drawString (short x, short y, const char* str) {
		stringRGBA (rPic, x, y, str, FG.r, FG.g, FG.b, FG.a);
		return *this;
	}
	PAINT& PAINT::drawString (short x, short y, const char* str, color_t C) {
		stringRGBA (rPic, x, y, str, XR(C), XG(C), XB(C), XA(C));
		return *this;
	}

#undef XR
#undef XG
#undef XB
#undef XA
}  // 命名空间 xege 结尾
